<?php
namespace app\common\model;

use think\Model;

class Mall extends Model
{
    protected $updateTime = false;
	protected $createTime = false;

 	
	public function mall()
    {
//        这是关联，1对1的
        return $this->hasMany('mall', 'parent_id', 'mall_id');
    }
    
    public static function del($mall_id = 0)
    {
        if (mall::where('parent_id', $mall_id)->count()) {
            throw new \Exception('删除失败，存在旗舰店');
        } elseif (self::where('parent_id', $mall_id)->count()) {
            throw new \Exception('删除失败，存在商城');
        } else {
            return self::where('mall_id', $mall_id)->delete();
        }
    }
    
}